import {Page} from '@/base/Page';
import {Company} from '@/base/model/Company';
import {getCompanyList} from '@/base/api/CompanyApi';

export class CompanySelectorBloc {

  paged: Page<Company> = new Page<Company>([], 0, 1, 15, 0, []);
  loading = false;

  load(name: string) {
    this.loading = true;
    return getCompanyList({
      pageIndex: 1,
      pageSize: 50,
      sortDirection: 'ASC',
      name
    }).then((res) => {
      this.paged = res.data;
    }).finally(() => {
      this.loading = false;
    });
  }
}
